<?php
final class DB 
{
	private $driver;
	
	public function __construct($driver, $hostname, $username, $password, $database) 
	{
		$driverArrays = array('dblib', 'firebird', 'pgsql', 'mysql');
		if (!in_array($driver,$driverArrays)) 
		{
			exit('Error: Could not load database type ' . $driver . '!');
		} 

		$dsn = "{$driver}:host={$hostname};dbname={$database}";
		$this->driver = new PDO($dsn, $username, $password);
	}
		
  	public function query($sql) {
		return $this->driver->query($sql);
  	}
	
	public function escape($value) {
		return $this->driver->quote($value);
	}

  	public function getLastId() {
		return $this->driver->lastInsertId();
  	}	
}
?>